package cli

import (
	"github.com/ihaiker/tfwrapper/internal/orch"
	"github.com/ihaiker/tfwrapper/internal/parser"
	"github.com/ihaiker/tfwrapper/internal/util"
	"github.com/urfave/cli/v2"
)

var runAll = &cli.Command{
	Name: "run-all", Usage: "Run all terraform modules",
	UsageText:       "Run all terraform modules",
	SkipFlagParsing: true,
	Action: showHelp(func(ctx *cli.Context) error {
		wrapper, err := parser.Parser(ctx.App.Version, *flags)
		if util.HasErrors(err) {
			return err
		}
		return orch.RunAll(wrapper, ctx.Args().Slice())
	}),
}

func init() {
	app.Commands = append(app.Commands, runAll)
}
